<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<input type="file" id="file" accept="image/*" onchange="upload()">
<button onclick="upload()">上传文件</button>

<hr>
<img src="empty.jpg"  onclick="file.click()" id="head"
    style="width: auto;height: auto;object-fit: cover;cursor: pointer">

<script>
    function upload(){
        if(file.files.length==0){
            alert("未选择文件");
            return ;
        }
        let fd=new FormData();
        fd.append("image",file.files[0]);

        axios.post( "upload.s", fd).then(function(res){
            alert(res.data.msg + ":" +res.data.data) ;
            head.src=res.data.data;

        });
    }
</script>

</body>
</html>